package com.txMsg.server.config;


import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {

//    @Bean(name="message")
//    public Queue queueMessage() {
//        return new Queue("topic.message");
//    }
    public static final String TXMSG_EXCHANGE= "tx_msg_exchange";
    @Bean
    public TopicExchange exchange() {
        return new TopicExchange(RabbitMQConfig.TXMSG_EXCHANGE);
    }
    /////////////////测试用-start///////////////////////
    public static final String TXMSG_QUEUE_TEST= "tx_msg_queue_test";
    @Bean(name=TXMSG_QUEUE_TEST)
    public Queue queueMessage() {
        return new Queue(TXMSG_QUEUE_TEST);
    }
    @Bean
    Binding bindingExchangeMessage(@Qualifier(TXMSG_QUEUE_TEST) Queue queueMessage, TopicExchange exchange) {
        return BindingBuilder.bind(queueMessage).to(exchange).with(TXMSG_QUEUE_TEST);
    }
    /////////////////测试用-end///////////////////////
}
